import React from 'react'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import * as msgActions from '../store/actions/socket'
import Chat from '../pages/chat/chat'
class ChatContainer extends React.Component{

    static navigationOptions = ({navigation}) => {
        const chatUserName = navigation.getParam("chatUserName")
        return  {
            headerTitle:chatUserName
        }
    }


    constructor(props) {
        super(props);
    }

    render(){
        return (
            <Chat {...this.props} />
        )
    }

}

const mapStateToProps = (state)=>{
    const socket = state.socket
    const user = state.user
    return {
        ...socket,
        ...user
    }
}

const mapDispatchToProps = (dispatch) => {
    const actionCreators = bindActionCreators(msgActions,dispatch)
    return {actionCreators,dispatch}
}

export default connect(mapStateToProps,mapDispatchToProps)(ChatContainer)